Statements and Functions > Activate

Activate

General Action Statement

Syntax samples

ACTIVATE <subroutine>({parameter1>,<parameter2>...})

ACTIVATE Sub1()

Description

Starts an independent subroutine. The calling logic then continues without waiting for the called subroutine to finish. Therefore, independent subroutines can run in parallel with the logic that called them. Independent subroutines are not entity or location dependent and run without regard to what happens inside the logic that called them.

 

Use ACTIVATE to process logic that has WAIT or WAIT...UNTIL statements when you do not want to use an entity to process the WAIT or WAIT...UNTIL statements. For example, an ACTIVATE in the initialization logic could call a subroutine that adjusts the arrival frequency for a type of entity depending on the time of day.

 

Independent subroutines called with ACTIVATE cannot use entity-specific or location-specific system functions. If the subroutine has a return value, then that value is ignored. External subroutines cannot be called with ACTIVATE, although they may be called from within an activated subroutine.

Valid In

Any logic.

Components

<subroutine>

The name of the subroutine to run. This name should appear exactly as if the subroutine were being called normally. Any return value for this function is ignored. See Subroutines.

<parameters>

The parameters that the subroutine normally takes.

Example

This example uses ACTIVATE in a model’s initialization logic to start a subroutine named Res_Log(). Res_Log() is a user-defined subroutine that logs every time that all units of a resource named Nurse are in use. After it logs the time that all units were busy, it waits ten minutes to check again. Note that the WHILE...DO loop in the subroutine is never exited. This technique allows the subroutine to run during the entire simulation.

 

Initialization Logic:

Activate Res_Log()

Res_Log() Subroutine Logic:

INT x = 1

WHILE x = 1 DO

{

IF FREEUNITS(Nurse)= 0 THEN

LOG "All workers busy",0

WAIT 10

}

See Also

XSUB(). Also see Subroutines.


© 2012 ProModel Corporation • 556 East Technology Avenue • Orem, UT 84097 • Support: 888-776-6633 • www.promodel.com